'*************************************************************************
' Configuration parameters                                              
' This Raduga add-in writes the name of the currently playing song
' to the file "C:\CurrentSong.txt" 

Dim outputFileName
outputFileName = "C:\CurrentSong.txt"

'*************************************************************************

' The Player_Start event is fired by Raduga whenever a new track starts
Sub Player_Start
	' Update the Raduga status bar
	Application.Statusbar = "Updating " & outputFileName

	' Get the name of the song that was just started
	Dim songName
	songName = GetDisplayName(Application.Player.FileName)

	' Write the song name to a text file
	Const ForWriting = 2
	Dim fso, f, ts, s
	Set fso = CreateObject("Scripting.FileSystemObject")
	fso.CreateTextFile outputFileName
	Set f = fso.GetFile( outputFileName )
	Set ts = f.OpenAsTextStream(ForWriting, vbUseDefault)

	ts.WriteLine songName

	ts.Close
End Sub

' get the display name of the song from a file name
Function GetDisplayName( fileName )
	GetDisplayName = Application.Playlist.DisplayNameOf( fileName )
End Function
